// [物对象] 接口
import { axios } from '@/utils/request';

/**
 * [物对象] 查询指定物对象
 * @params params
 * {
    {"id":{"required":true,"type":"integer"}}
   }
 */
export function getDatahubThingInstance(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/instance',
    params
  })
}

/**
 * [物对象] 新增物对象
 * @params data
 * {
    {"description":{"description":"物对象描述","type":"string"}},
    {"name":{"description":"物对象名称","type":"string"}},
    {"relationThingModelId":{"description":"关联的物模型ID","type":"integer"}},
    {"thingParameters":{"description":"物对象的参数配置","type":"array"}},
    {"variables":{"description":"物对象的变量配置","type":"array"}}
   }
 */
export function postDatahubThingInstance(data) {
  return axios({
    method: 'post',
    url: 'datahub/thing/instance',
    data
  })
}

/**
 * [物对象] 编辑物对象
 * @params data
 * {
    {"description":{"description":"物对象描述","type":"string"}},
    {"id":{"type":"integer"}},
    {"name":{"description":"物对象名称","type":"string"}},
    {"relationThingModelId":{"description":"关联的物模型ID","type":"integer"}},
    {"thingParameters":{"description":"物对象的参数配置","type":"array"}},
    {"variables":{"description":"物对象的变量配置","type":"array"}}
   }
 */
export function putDatahubThingInstance(data) {
  return axios({
    method: 'put',
    url: 'datahub/thing/instance',
    data
  })
}

/**
 * [物对象] 删除物对象
 * @params params
 * {
    {"id":{"required":true,"type":"integer"}}
   }
 */
export function deleteDatahubThingInstance(params) {
  return axios({
    method: 'delete',
    url: 'datahub/thing/instance',
    params
  })
}

/**
 * [物对象] 分页查询物对象
 * @params params
 * {
    {"name":{"required":false,"type":"string"}},
    {"modelId":{"required":false,"type":"integer"}},
    {"pageNo":{"required":false,"type":"integer"}},
    {"pageSize":{"required":false,"type":"integer"}}
   }
 */
export function getDatahubThingInstancePage(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/instance-page',
    params
  })
}

/**
 * [物对象] 拷贝物对象
 * @params data
 * {
    {"description":{"description":"拷贝后的物对象描述","type":"string"}},
    {"id":{"description":"拷贝原始物对象ID","type":"integer"}},
    {"name":{"description":"拷贝后的物对象名称","type":"string"}}
   }
 */
export function putDatahubThingInstanceCopy(data) {
  return axios({
    method: 'put',
    url: 'datahub/thing/instance/copy',
    data
  })
}

/**
 * [物对象] 查询指定物对象当前值
 * @params data
 * {
    {"id":{"type":"integer"}},
    {"parameterValues":{"type":"array"}}
   }
 */
export function postDatahubThingInstanceData(data) {
  return axios({
    method: 'post',
    url: 'datahub/thing/instance/data',
    data
  })
}

/**
 * [物对象] 查询指定物对象的指标信息
 * @params params
 * {
    {"name":{"required":false,"type":"string"}}
   }
 */
export function getDatahubThingInstanceIndexList(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/instance/index-list',
    params
  })
}

/**
 * [物对象] 使用参数计算物对象实时值
 * @params data
 * {
    {"parameterValues":{"type":"array"}},
    {"relationThingModelId":{"type":"integer"}},
    {"thingParameters":{"type":"array"}},
    {"variables":{"type":"array"}}
   }
 */
export function postDatahubThingInstanceRealtimeData(data) {
  return axios({
    method: 'post',
    url: 'datahub/thing/instance/realtime-data',
    data
  })
}


/**
 * [物对象] 主动校验
 * @params params
 * {
    {"id":{"required":false,"type":"integer"}},
    {"field":{"required":false,"type":"string"}},
    {"value":{"required":false,"type":"object"}}
   }
 */
export function getDatahubThingInstanceVerification(params) {
  return axios({
    method: 'get',
    url: 'datahub/thing/instance/verification',
    headers: { validate: true },
    params
  })
}